package com.buer.storage.service.impl;

import com.buer.storage.dao.CorderDao;
import com.buer.storage.dao.CorderResultDao;
import com.buer.storage.entity.Corder;
import com.buer.storage.entity.CorderResult;
import com.buer.storage.service.CorderResultService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;

@Service
public class CorderResultServiceImpl implements CorderResultService {
    @Resource
    private CorderResultDao corderResultDao;

    @Resource
    private CorderDao corderDao;

    @Override
    public int insertCorderResult(List<CorderResult> corderResults) {
        int num= 0 ;

        if (corderResults.size()>0){
            for (CorderResult cr:corderResults) {
                cr.setUpdateTime(new Date());
                num+=corderResultDao.insertCorderResult(cr);


                Corder corder = corderDao.findCorder(cr.getCheckId());
                corder.setCheckStatus(1);
                corderDao.updateCorder(corder);
            }
        }
    return num;
    }
}
